<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"    uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/submenu.jsp"%>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
    
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">回单确认</li>
    </ol>
    
    <div class="ms-content-layout">
    
      <div class="block-heading">
         <h5>基本信息</h5>
      </div>
      
      <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/trans-orders/${dispatchOrder.id}/confirm"
            data-redirect="${ctx.host}/trans-orders?${sessionScope.transOrderQueryString}">
        
        <input type="hidden" name="_method" value="PATCH" >
        <input type="hidden" name="itemQuantity" value="" >
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">调度指令组号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.shipmentGroupId}</p>
          </div>
          <label class="col-xs-2 control-label">派车单日期：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatDate value="${dispatchOrder.dispatchDate}" pattern="yyyy-MM-dd"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">起始地：</label>
          <div class="col-xs-3 ">
            <p class ="form-control-static">
              ${empty dispatchOrder.startFacilityId ? '' : ( persist.loadPlace(dispatchOrder.startFacilityId).code ).concat( '-' ).concat( persist.loadPlace(dispatchOrder.startFacilityId).name )}
            </p>
          </div>
          <label class="col-xs-2 control-label">目的地：</label>
           <div class="col-xs-3 ">
             <p class ="form-control-static">
               ${empty dispatchOrder.destinationFacilityId ? '' : (persist.loadPlace(dispatchOrder.destinationFacilityId).code).concat('-').concat(persist.loadPlace(dispatchOrder.destinationFacilityId).name)}
             </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">驳运车号：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">
               ${empty dispatchOrder.vehicleId ? '' : (persist.vehicle(dispatchOrder.vehicleId).code).concat('-').concat(persist.vehicle(dispatchOrder.vehicleId).name)}
            </p>
          </div>
          <label class="col-xs-2 control-label">行驶公里数：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${dispatchOrder.facilityDistance}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾驶员：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">
               ${empty dispatchOrder.mainDriverId ? '' : (persist.employee(dispatchOrder.mainDriverId).code).concat('-').concat(persist.employee(dispatchOrder.mainDriverId).name)}
            </p>
          </div>
          <label class="col-xs-2 control-label">第一副驾驶员：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">
            ${empty dispatchOrder.firstViceDriverId ? '' : (persist.employee(dispatchOrder.firstViceDriverId).code).concat('-').concat(persist.employee(dispatchOrder.firstViceDriverId).name)}
            </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">路桥费：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).roadFee}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">修理费：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).repairFee}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">轮胎费：</label>
          <div class="col-xs-8">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).tyreFee}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾重载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).mainDriverFullSalary}" minFractionDigits="2"/></p>
          </div>
          
          <label class="col-xs-2 control-label">主驾空载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> <fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).mainDriverEmptySalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">主驾工资：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).mainDriverSalary}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">第一副驾重载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).firstViceDriverFullSalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">第一副驾空载工资单价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).firstViceDriverEmptySalary}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">第一副驾工资：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).firstViceDriverSalary}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">重载油耗：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).fullOilUsagePerKm}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">空载油耗：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).emptyOilUsagePerKm}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">装载能力：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.fullLoadNumber}</p>
          </div>
          <label class="col-xs-2 control-label">加油类型：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${persist.transportCost(dispatchOrder.id).oilTypeId == 3 ? '0#' : '10#'}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">加油量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).oilUsage}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">内部加油量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).internalOilUsage}" minFractionDigits="2"/> </p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">内部油价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).internalOilPrice}" minFractionDigits="2"/></p>
          </div>
          <label class="col-xs-2 control-label">外部油价：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).externalOilPrice}" minFractionDigits="2"/></p>
          </div>
        </div>
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">油费：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"><fmt:formatNumber value="${persist.transportCost(dispatchOrder.id).totalOilFeeReimbursed}" minFractionDigits="2"/></p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">是否打印报销单：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.expenseReimbursed ? "是" : "否"}</p>
          </div>
          <label class="col-xs-2 control-label">是否已报销：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${dispatchOrder.expenseReimbursed ? "是" : "否"}</p>
          </div>
        </div>
        
        <div class="form-group ms-form-group">
          <label class="col-xs-2 control-label">是否回单确认：</label>
          <div class="col-xs-3">
            <p class ="form-control-static">${dispatchOrder.accomplishConfirm ? "是" : "否"}</p>
          </div>
          <label class="col-xs-2 control-label">回单数量：</label>
          <div class="col-xs-3">
            <p class ="form-control-static"> ${dispatchOrder.accomplishConfirmNumber}</p>
          </div>
        </div>

        <div class="block-heading">
         <h5>商品车明细列表</h5>
        </div>
      
        <c:forEach items="${shipmentOrders}" var="order">
        
          <div class="form-horizontal ms-form form-personal-info">
        
            <div class="form-group ms-form-group yellow-bar">
              <div class="col-xs-2">
                <p class ="form-control-static">订单号：${order.code}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">调度指令号：${order.shipmentNumber}</p>
              </div>
               <div class="col-xs-2">
                <p class ="form-control-static">客户：${order.client}</p>
              </div>
              <div class="col-xs-2 ">
                <p class ="form-control-static">订单起始地：${order.startFacility}</p>
              </div>
              <div class="col-xs-2 ">
                <p class ="form-control-static">订单目的地：${order.endFacility}</p>
              </div>
              <div class="col-xs-2">
                <p class ="form-control-static">结算公里数：${order.kilometer}  &nbsp;&nbsp; &nbsp;&nbsp;单价：<fmt:formatNumber value="${order.contractRate}" minFractionDigits="2"/></p>
              </div>
            </div>
            
          </div>
        
          <table class="table table-hover ms-table order-item-table">
            <thead>
              <tr>
                <th class="order-item"><input type="checkbox" id="item-${order.id}"/></th>
                <th>VIN码</th>
                <th>数量</th>
                <th>车型</th>
                <th>颜色</th>
                <th>运输方式</th>
                <th>装车道号</th>
                <th>制造商</th>
                <th>起始地</th>
                <th>目的地</th>
                <th>目的地地址</th>
                <th>目的地联系电话</th>
                <th>预计起运时间</th>
                <th>预计装运时间</th>
                <th>是否电子回单确认</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${order.shipmentOrderItems}" var="item">
                <tr>
                  <td class="order-item-${order.id}">
                    <c:choose>
                      <c:when test="${not item.accomplishConfirm}">
                        <input type="checkbox" name="itemIds" value="${item.id}" id="${item.id}"/>
                      </c:when>
                      <c:when test="${item.accomplishConfirm}">
                        <span class="glyphicon glyphicon-ok"></span>
                      </c:when>
                    </c:choose>
                  </td>
                  <td>${item.vinCode}</td>
                  <td id="item-quantity-${item.id}">${item.quantity}</td>
                  <td>${item.carType}</td>
                  <td>${item.carColor}</td>
                  <td>${item.transType}</td>
                  <td>${item.driveWay}</td>
                  <td>${item.manufactor}</td>
                  <td>${item.startFacility}</td>
                  <td>${item.endFacility}</td>
                  <td>${item.destinationAddress}</td>
                  <td>${item.destinationTelecomNumber}</td>
                  <td>${item.deptDate}</td>
                  <td>${item.loadDate}</td>
                  <td>
                    <c:choose>
	                    <c:when test="${item.electronicConfirm eq true}">
	                      <a href="${ctx.host}/shipment-lines/${item.shipmentId}/electronic" data-target="#shipment-electronic" data-toggle="modal">是(查看详情)</a>
	                    </c:when>
	                    <c:otherwise>
	                      <span>否</span>
	                    </c:otherwise>
                    </c:choose>
                  </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>

        </c:forEach>
        
        <div class="invalid-message" style="display: none;">
          <h6>提醒&nbsp;:&nbsp;请至少选择一辆商品车</h6>
        </div>
        
        <div class="form-group ms-form-group">
          <div class="col-xs-1">
            <button type="button" id="select-all" value="true" class="btn btn-default">全选</button>
          </div>
        </div>

        <div class="form-group ms-form-group">
          <div class="col-xs-6 col-xs-offset-3 ms-operation-group top-margin-20 text-center">
            <div class="col-xs-5">
              <button type="reset" class="btn btn-block btn-default">重置</button>
            </div>
            <div class="col-xs-5">
              <button type="submit" class="btn btn-block btn-primary">确认</button>
            </div>
          </div>
        </div>

      </form>
    
    </div> 
  </div>       
  
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/business/trans-order/trans-order-confirm.js" />
  <script type="text/javascript">
    require(['page/business/trans-order/trans-order-confirm'], function(page) {
      page.init({
        isAllAccomplishConfirmed: '${dispatchOrder.isAllAccomplishConfirmed()}' 
      })
    })
  </script>

</body>
</html>